package com.vast.admin.api.entity;

import lombok.Data;

import java.util.ArrayList;
import java.util.List;

@Data
public class SignContract {

    /**
     * 合同ID
     */
    private String contractId;

    /**
     * 签署者账号
     */
    private String signerAccount;

    private List<SignaturePosition> signaturePositions;

    @Data
    public class SignaturePosition {

        /**
         * 页码。1开始，不能超过实际页数
         */
        private String pageNum;

        /**
         * 横坐标，按页面尺寸的百分比计算，取值0.0 - 1.0。以左上角为原点
         */
        private String x;

        /**
         * 纵坐标，同上
         */
        private String y;

        public SignaturePosition() {

        }

        public SignaturePosition(String pageNum, String x, String y) {
            this.pageNum = pageNum;
            this.x = x;
            this.y = y;
        }
    }

    /**
     * 添加签章坐标
     * @param pageNum
     * @param x
     * @param y
     */
    public void add(Integer pageNum, String x, String y) {
        if (signaturePositions == null) {
            signaturePositions = new ArrayList<>();
        }
        signaturePositions.add(new SignaturePosition(pageNum + "", x, y));
    }
}
